<#include "../common/_layout.html" />
<@head title="投诉与建议管理审核">
<style type="text/css">
    .cll {
        background-color: #ddd;
    }
</style>
<link rel="stylesheet" href="${ctx}/adminlte/plugins/bootstrap-fileinput/fileinput.min.css">
<link rel="stylesheet" href="${ctx}/adminlte/plugins/fancybox/jquery.fancybox.css" media="screen">
</@head>
<@layout menu='/complaintadvice'>
<section class="content-header">
    <h1>
        ${pageTitleBread.department!pageTitleBread.default!}
    </h1>
    <ol class="breadcrumb">
        <li><a href="javascript:void(0);" onclick="location.href='${ctx}${pageTitleBread.breadHomeMethod!}'">首页</a></li>
        <li><a href="javascript:void(0);" onclick="location.href='${ctx}${pageTitleBread.url!}'">${pageTitleBread.pageTitle!}</a></li>
        <li class="active">${pageTitleBread.nowBread!}</li>
    </ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                    <legend>审核</legend>
                    <input type="hidden" name="id" id="id" value="${complaintAdvice.id!}">
                    <div class="form-group">
                        <label for="adv_type">类型</label>
                        <textarea disabled class="form-control" id="adv_type" name="adv_type" rows="1"><#if complaintAdvice.adv_type??&&complaintAdvice.adv_type==0>投诉举报</#if><#if complaintAdvice.adv_type??&&complaintAdvice.adv_type==1>意见建议</#if><#if complaintAdvice.adv_type??&&complaintAdvice.adv_type==2>其他</#if></textarea>
                    </div>
                    <div class="form-group">
                        <label for="content">问题</label>
                        <textarea disabled id="content" name="content" class="form-control" rows="5">${complaintAdvice.content!}</textarea>
                    </div>
                    <div>
                        <#list list as upload>
                            <a class="fancybox" data-fancybox="gallery" href="${ctx}${upload.url!}"><img width ="200px" src="${ctx}${upload.url!}"> </a>
                        </#list>
                    </div>

                    <div class="form-group">
                        <label for="advice">建议</label>
                        <textarea disabled id="advice" name="advice" class="form-control" rows="5">${complaintAdvice.advice!}</textarea>
                    </div>
                    <div class="form-group">
                        <label for="name">姓名</label>
                        <input disabled type="text" class="form-control" id="name" name="name" placeholder="姓名" value="${complaintAdvice.name!}">
                    </div>
                    <div class="form-group">
                        <label for="phone">电话</label>
                        <input disabled type="text" class="form-control" id="phone" name="phone" placeholder="电话" value="${complaintAdvice.phone!}">
                    </div>
                    <!--<div class="form-group">
                        <label for="wx_user_id">微信号</label>
                        <input disabled type="number" class="form-control" id="wx_user_id" name="wx_user_id" placeholder="微信号" value="${complaintAdvice.wx_user_id!}">
                    </div>-->
                    <!--<div class="form-group">-->
                        <!--<input type="radio" name="status" value="1">审核通过-->
                        <!--<input type="radio" name="status" value="2">审核不通过-->
                    <!--</div>-->
                    <!--<button type="submit" class="btn btn-primary">提交</button>-->
                <#if complaintAdvice.status??&&complaintAdvice.status==0>
                <button class="btn btn-primary" onclick="assign(${complaintAdvice.id!})">指派</button>
                <button class="btn btn-primary" onclick="location.href = '${ctx}/complaintadvice/review?status=3&id=${complaintAdvice.id!}'">不予处理</button>
                <button class="btn btn-cancle" onclick="javascript :history.back(-1);">返回</button>
                </#if>
                <#if complaintAdvice.status??&&complaintAdvice.status==1>
                <div class="form-group">
                        <label for="result">处理结果反馈</label>
                        <textarea disabled id="result" name="result" class="form-control" rows="7">${complaintAdvice.result!}</textarea>
                    </div>
                <button class="btn btn-cancle" onclick="javascript :history.back(-1);">返回</button>
                </#if>
                <#if complaintAdvice.status??&&complaintAdvice.status==2>
                <div class="form-group">
                        <label for="result">处理结果反馈</label>
                        <textarea id="result" name="result" class="form-control" rows="7"></textarea>
                    </div>
                    <button class="btn btn-primary" onclick="dosubmit('${ctx}/complaintadvice/results')">处理完成</button>
<!--                     <button class="btn btn-primary" onclick="location.href = '${ctx}/complaintadvice/results?result=${result!}&id=${complaintAdvice.id!}'">处理完成</button> -->
                    <button class="btn btn-cancle" onclick="javascript :history.back(-1);">返回</button>
                </#if>
                <#if complaintAdvice.status??&&complaintAdvice.status==3>
                	<button class="btn btn-primary" onclick="assign(${complaintAdvice.id!})">指派</button>
                    <button class="btn btn-primary" onclick="location.href = '${ctx}/complaintadvice/review?status=2&id=${complaintAdvice.id!}'">不予处理</button>
                    <button class="btn btn-cancle" onclick="javascript :history.back(-1);">返回</button>
                </#if>
            </div>
        </div>
    </div>
</section>
</@layout>
<@scripts>
<script type="text/javascript" src="${ctx}/adminlte/plugins/bootstrap-fileinput/fileinput.min.js"></script>
<script type="text/javascript" src="${ctx}/adminlte/plugins/bootstrap-fileinput/zh.js"></script>
<script type="text/javascript" src="${ctx}/adminlte/plugins/fancybox/jquery.fancybox.js"></script>
<script type="text/javascript" src="${ctx}/adminlte/plugins/bootbox/bootbox.min.js"></script>
<script type="text/javascript" src="${ctx}/adminlte/plugins/jQuery/jQuery-2.1.4.min.js"></script>
<script type="text/javascript" src="${ctx}/adminlte/plugins/moment/moment.min.js"></script>
<script type="text/javascript" src="${ctx}/adminlte/plugins/moment/zh-cn.js"></script>
<script type="text/javascript" src="${ctx}/adminlte/plugins/daterangepicker/daterangepicker.js"></script>
<script type="text/javascript">
    function assign(id){
    	$.ajax({
    		"type":'post',
    		"url":'${ctx}/complaintadvice/findTowns',
    		"dataType":'json',
    		"data":{
    		},
    	"success":function(data){
    		var map = data.townsName;
    		var select = $("<select id='seltowns' class='form-control'>")
    		for(var key in map){
    			var option = $("<option>").val(key).text(map[key]);
    			select.append(option);
    		}
    		
    		bootbox.dialog({
    			title:'请指派区域',
    			message:"<div>"+select.prop("outerHTML")+" <input type='date' class='form-control' name='assintime' id='assintime' placeholder='2017-08-21'><select class='form-control' id='degree'><option value='0'>一般</option><option value='1'>严重</option><option value='2'>非常严重</option></select></div>",
    			buttons:{
    				ok: {
    			        label: "确定",
    			        className: 'btn-info',
    			        callback: function(){
    			        	var seltowns = $("#seltowns").val();
    			        	var assintime = $("#assintime").val();
    			        	var degree = $("#degree").val();
    			            $.ajax({
    			            	type:'post',
    			            	url:'${ctx}/complaintadvice/assin',
    			            	dataType:'json',
    			            	data:{
    			            		seltowns : seltowns,
    			            		assintime : assintime,
    			            		degree : degree,
    			            		id : id
    			            	},
    			            	success : function(data) {
    								bootbox.alert(data.message, function () {
                                        window.location.href="${ctx}/complaintadvice";
                                    });
    							}
    			            });
    			            }
    			        }
    			}
    		})
    	}
    		
    	});
    	
    }
    
    function dosubmit(url){
    	var result = $("#result").val();
    	var id = $("#id").val();
    	$.ajax({
    		type:'post',
        	url:url,
        	dataType:'json',
        	data:{
        		result : result,
        		id : id
        	},
        	success : function(data) {
				bootbox.alert(data.message, function () {
                    window.location.href="${ctx}/complaintadvice";
                })
        	}
    	})
    }
    
</script>

</@scripts>
